//------------------------------------------------------------------------------
// JAVA    : ezCall
//
// Made by : Cho HanCheol.
// Date    : 2011. 3. 9.
//------------------------------------------------------------------------------

package ezCall;

import javax.microedition.pim.ContactList;
import javax.microedition.pim.PIM;
import javax.microedition.pim.PIMException;
import javax.microedition.pim.PIMItem;

import net.rim.blackberry.api.pdap.BlackBerryPIMList;
import net.rim.blackberry.api.pdap.PIMListListener;
import net.rim.blackberry.api.phone.Phone;
import net.rim.device.api.system.ApplicationManager;
import net.rim.device.api.system.ControlledAccessException;
import net.rim.device.api.system.KeyListener;
import net.rim.device.api.system.PersistentObject;
import net.rim.device.api.system.PersistentStore;
import net.rim.device.api.ui.UiApplication;
import net.rim.device.api.ui.component.Dialog;

class DebugMode
{
	public static final boolean SaveMode = true;
}


//------------------------------------------------------------------------------
// CLASS : ezCall
//
// WORK : 
//------------------------------------------------------------------------------
public final class ezCall extends UiApplication 
{

    private ezCall_Screen  _ezCall_Screen;
    
    
    private static PersistentObject _persist;
    private static Option_Model     _Option_Model;
    

    static 
    {
    	if( DebugMode.SaveMode )
    	{
	        _persist = PersistentStore.getPersistentObject( 0x805c524a0059d52dL ); // chcbaram.ezcall
	        
	        synchronized( _persist ) 
	        {
	            if( _persist.getContents() == null ) 
	            {
	                _persist.setContents( new Option_Model() );
	                _persist.commit();
	                
	            }
	        }
	               
	        _Option_Model = (Option_Model) _persist.getContents();  

    	}
    }
    
    
    
	//--------------------------------------------------------------------------
	// 함수 : main
	// 기능 : 
	//--------------------------------------------------------------------------
	public static void main(String[] args) 
	{
		
		if( ApplicationManager.getApplicationManager().inStartup() )
		{
			if( DebugMode.SaveMode )
			{
	            if( _Option_Model.Get_AutoStart() == _Option_Model.AUTO_START_YES )
	            {
	    	        ezCall theApp = new ezCall();
	    	        theApp.enterEventDispatcher();
	            }
	            else
	            {
	            	System.exit( 0 );
	            }

			}
		}
        else
        {
	        // 어플리케이션 인스턴스 생성
			//
	        ezCall theApp = new ezCall();
	        
	        // 명령어 처리 프로세서 실행
	        //
	        theApp.enterEventDispatcher();
        }		
		
		
		/*
        // 어플리케이션 인스턴스 생성
		//
        ezCall theApp = new ezCall();
        
        // 명령어 처리 프로세서 실행
        //
        theApp.enterEventDispatcher();		
		*/
		
		
		
		/*
        if ( args.length > 0 && args[0].equals( "autostartup" ) ) 
        {
            try 
            {
                if( _Option_Model.Get_AutoStart() == _Option_Model.AUTO_START_YES )
                {
        	        ezCall theApp = new ezCall();
        	        theApp.enterEventDispatcher();
                }
                else
                {
                	System.exit( 0 );
                }
            }
            catch ( ControlledAccessException e ) 
            {
                Dialog.alert( "Access to Phone API restricted by system administrator." );
                System.exit( 1 );
            }
        } 
        else
        {
	        // 어플리케이션 인스턴스 생성
			//
	        ezCall theApp = new ezCall();
	        
	        // 명령어 처리 프로세서 실행
	        //
	        theApp.enterEventDispatcher();
        }
        */
	}


	// Constructor
	private ezCall()
	{   
		_ezCall_Screen = new ezCall_Screen();
		
		pushScreen( _ezCall_Screen ); 
	}

}
